import axios from 'axios';

interface IHttp {
  Get(url: string): Promise<any>;
  Post(url: string, data: any): Promise<any>;
}

export class Http implements IHttp {

  constructor() {
    axios.defaults.headers['Content-Type'] = 'application/json; charset=UTF-8';
  }

  public async Put(url: string, data: any): Promise<any> {
    return await axios.put(url, data)
      .then(function (response) {
        // console.log('response',response)
        return response;
      })
      .catch(function (error) {
        console.log(error);
      });
  }
  public async Post(url: string, data: any): Promise<any> {
    return await axios.post(url, data)
      .then(function (response) {
        // console.log('response',response)
        return response;
      })
      .catch(function (error) {
        console.log(error);
      });
  }

  public async Get(url: string): Promise<any> {
    return await axios.get(url)
      .then(function (response) {
        return response;
      })
      .catch(function (error) {
        console.log(error);
      });
  }
}